<template>
  <div class="app-container" >
    <uc-table url="admin/maintenanceFeedback/getInMaintenanceFeedbackLogPage" name="设备反馈单" ref="feedbacklogTable" pageable table-border :search-form="searchForm">
      <template slot="searchForm">
        <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">
          <!--搜索输入框-->
          <el-form-item>
            <el-input type="text" v-model="searchForm.maintenanceRecordName" placeholder="工单名称" clearable @clear="clearInput()"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" class="filter-item" @click="handleSearch()">查询</el-button>
          </el-form-item>
        </el-form>
      </template>

      <template slot="columns">
        <el-table-column prop="maintenanceRecordName" label="工单名称" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="reportPerson" label="反馈人" align="left" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{scope.row.reportPerson | feedbackPerson}}
          </template>
        </el-table-column>
        <el-table-column prop="feedBackTime" label="反馈时间" align="left" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{scope.row.feedBackTime  | dateFormat}}
          </template>
        </el-table-column>
        <el-table-column prop="feedBackRemark" label="反馈详情" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="maintenanceRecordType" label="工单状态" align="left" show-overflow-tooltip >
          <template slot-scope="scope">
            {{scope.row.maintenanceRecordType  | workOrderStatus}}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作" width="220" align="left" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <!--编辑按钮-->

            <el-button size="20px" icon="el-icon-info" type="success" @click="handleInfo(scope.row)">详情</el-button>
            <el-button size="20px" type="danger" icon="el-icon-delete" :loading="deleteLoading" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </template>
    </uc-table>
  </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";

import {deleteInMaintenanceFeedbackLog} from "@/api/feedbacklog"
import {getMaintenanceRecordList} from "@/api/maintenanceRecord";

export default {
  name: "list",
  components: {UcTable},
  data(){
    return{
      searchForm:{
        deleted:false,

      },
      deleteLoading:false,
    }
  }, created() {
    this.getInMaintenanceRecordVo()
  },
  methods:{
    clearInput(){
      //清除输入框
      this.searchForm.maintenanceRecordId = null
      this.handleSearch()
    },
    handleSearch(){
      this.$refs.feedbacklogTable.getTableData(1)
    },
    handleAdd(){
      this.$router.push("/maintenance/maintenanceFeedbackEdit/0")
    },
    handleEdit(val){
      this.$router.push("/maintenance/maintenanceFeedbackEdit/"+val.id)
    },
    handleInfo(val){
      this.$router.push("/maintenance/maintenanceFeedbackInfo/"+val.id)
    },
    handleDelete(val){
      this.$confirm('您确定要执行删除'+val.disPlayName+'这条反馈工单吗？', '提醒信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteLoading = true
        deleteInMaintenanceFeedbackLog(val).then(res=>{
          this.deleteLoading = false
          this.$notify.success({
            title: '成功',
            message: "删除维保反馈工单成功"
          })
          this.handleSearch()
        }).catch(error=>{
          error.title="失败"
          })
        }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });

    },
    getInMaintenanceRecordVo() {
      getMaintenanceRecordList({deleted:false}).then(res => {
        this.$notify.success({
          title: '成功',
          message: "查询工单信息成功"
        })
        this.handleSearch()
      })
    },
  }

}
</script>

<style scoped>

</style>